package com.zzw.controller;

import com.github.pagehelper.PageInfo;
import com.zzw.bean.Msg;
import com.zzw.bean.Order;
import com.zzw.bean.OrderItem;
import com.zzw.bean.Product;
import com.zzw.service.OrderService;
import com.zzw.service.ProductService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/selectOrderList")
    public Msg selectOrderList() {
        List<Order> orderList = orderService.selectOrderList();
        return Msg.success().add("orderList", orderList);
    }

    @GetMapping("/selectOrderById")
    public Msg selectOrderById(@RequestParam("id") Long id) {
        Order order = orderService.selectOrderById(id);
        return Msg.success().add("order", order);
    }

    @PutMapping("/updateOrder")
    public Msg updateOrder(@RequestBody Order order) {
        orderService.updateOrder(order);
        return Msg.success();
    }

    @PostMapping("/insertOrder")
    public Msg insertOrder(@RequestBody Order order) {
        orderService.insertOrder(order);
        return Msg.success();
    }
}
